package com.ruge.core.domain;

import com.vladmihalcea.hibernate.type.json.JsonType;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @author ruge.wu
 * @since 2021/12/8 13:49
 */
@Getter
@Setter
@MappedSuperclass
@EntityListeners({AuditingEntityListener.class})
@TypeDefs({@TypeDef(name = "json", typeClass = JsonType.class)})
public class BaseDomain {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(columnDefinition = "int comment '主键id'")
    private Long id;
    @CreatedBy
    @Column(columnDefinition = "int comment '创建人id'")
    private Long createdBy;
    @CreatedDate
    @Column(columnDefinition = "datetime comment '创建时间'")
    private Date createdTime;
    @LastModifiedBy
    @Column(columnDefinition = "int comment '更新人id'")
    private Long updatedBy;
    @LastModifiedDate
    @Column(columnDefinition = "datetime comment '更新时间'")
    private Date updatedTime;
    @Column(columnDefinition = "varchar(600) comment '备注'")
    private String remark;
    @Column(columnDefinition = "bit comment '数据有效性'")
    private Boolean isValid = true;
}
